package com.juzipi.mp.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.juzipi.mp.entity.Student;
import com.juzipi.mp.service.StudentService;
import com.juzipi.mp.service.impl.StudentServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author juzipi
 * @Date 2021/8/13 16:48
 * @Info
 */
@RestController
@RequestMapping("stu")
public class StudentController {

    @Autowired
    private StudentService studentService;


    @GetMapping("get/{age}")
    public Student getStudent(@PathVariable Integer age){
        LambdaQueryWrapper<Student> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Student::getAge,age);
        return studentService.getOne(queryWrapper);
    }

    @PostMapping("post")
    public Boolean saveStudent(@RequestBody Student student){
        boolean save = studentService.save(student);
        return save;
    }


}
